/*
 * AssignDataFileBO.java 
 * 
 * Copyright 2009 Wangfeng Beijing Inc. 
 * All rights reserved. 
 * 
 * Created on 2012-08-09
 */

package com.bjtech.domain.query;

import java.util.Date;
import com.bjtech.web.util.SelectBean;
import org.ssi.web.util.QuerySpecTpl;

/**
 * 功能概述:分配表数据文件 <br>
 * 
 * @author 王峰
 */

public class AssignDataFileQuerySpec extends SelectBean {
	/* */
	private Long id;
	/* */
	private String file_name;
	/* */
	private Date upload_date;
	private Date b_upload_date;
	private Date e_upload_date;
	/* */
	private Float file_size;
	/* */
	private Long record_num;
	/* */
	private Long success_num;
	/* */
	private Float upload_per;
	/* */
	private String upload_man;

	@Override
	public void queryParamString() {
		StringBuilder fromPart = new StringBuilder(" where 1=1");

		if (this.isAll != null && this.isAll.intValue() != 1) {
			if (QuerySpecTpl.isValid(id)) {
				fromPart.append(" and a.id = ");
				fromPart.append(id);
			}

			if (QuerySpecTpl.isValid(file_name)) {
				fromPart.append(" and a.file_name like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(file_name);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(upload_date)) {
				fromPart
						.append(" and str_to_date(a.upload_date,'%Y-%m-%d')=str_to_date(CONCAT(''',");
				fromPart.append(upload_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(b_upload_date)) {
				fromPart
						.append(" and str_to_date(a.upload_date,'%Y-%m-%d')>=str_to_date(CONCAT(''',");
				fromPart.append(b_upload_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(e_upload_date)) {
				fromPart
						.append(" and str_to_date(a.upload_date,'%Y-%m-%d')<=str_to_date(CONCAT(''',");
				fromPart.append(e_upload_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}

			if (QuerySpecTpl.isValid(file_size)) {
				fromPart.append(" and a.file_size = ");
				fromPart.append(file_size);
			}

			if (QuerySpecTpl.isValid(record_num)) {
				fromPart.append(" and a.record_num = ");
				fromPart.append(record_num);
			}

			if (QuerySpecTpl.isValid(success_num)) {
				fromPart.append(" and a.success_num = ");
				fromPart.append(success_num);
			}

			if (QuerySpecTpl.isValid(upload_per)) {
				fromPart.append(" and a.upload_per = ");
				fromPart.append(upload_per);
			}

			if (QuerySpecTpl.isValid(upload_man)) {
				fromPart.append(" and a.upload_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(upload_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(this.direction)
					&& QuerySpecTpl.isValid(this.sort)) {
				fromPart.append(" order by ");
				fromPart.append(this.sort);
				fromPart.append(" ");
				fromPart.append(this.direction);
			} else {
				fromPart.append(" order by ");
				fromPart.append("id");
				fromPart.append(" ");
				fromPart.append("desc");

			}
		}
		super.setQueryString(fromPart.toString());
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getFile_name() {
		return this.file_name;
	}

	public void setFile_name(String file_name) {
		this.file_name = file_name;
	}

	public Date getUpload_date() {
		return this.upload_date;
	}

	public void setUpload_date(Date upload_date) {
		this.upload_date = upload_date;
	}

	public Date getB_upload_date() {
		return this.b_upload_date;
	}

	public void setB_upload_date(Date b_upload_date) {
		this.b_upload_date = b_upload_date;
	}

	public Date getE_upload_date() {
		return this.e_upload_date;
	}

	public void setE_upload_date(Date e_upload_date) {
		this.e_upload_date = e_upload_date;
	}

	public Float getFile_size() {
		return this.file_size;
	}

	public void setFile_size(Float file_size) {
		this.file_size = file_size;
	}

	public Long getRecord_num() {
		return this.record_num;
	}

	public void setRecord_num(Long record_num) {
		this.record_num = record_num;
	}

	public Long getSuccess_num() {
		return this.success_num;
	}

	public void setSuccess_num(Long success_num) {
		this.success_num = success_num;
	}

	public Float getUpload_per() {
		return this.upload_per;
	}

	public void setUpload_per(Float upload_per) {
		this.upload_per = upload_per;
	}

	public String getUpload_man() {
		return this.upload_man;
	}

	public void setUpload_man(String upload_man) {
		this.upload_man = upload_man;
	}
}
